package com.yunyouyi.cpicture.application.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunyouyi.cpicture.infrastructure.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.yunyouyi.cpicture.interfaces.dto.picture.*;
import com.yunyouyi.cpicture.domain.picture.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunyouyi.cpicture.domain.user.entity.User;
import com.yunyouyi.cpicture.interfaces.vo.picture.PictureVO;

import javax.servlet.http.HttpServletRequest;

/**
* @author yunyouyi
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-04-04 10:55:47
*/
public interface PictureApplicationService extends IService<Picture> {

    /**
     * 上传图片
     * @param inputSource
     * @param pictureUploadDTO
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(Object inputSource, PictureUploadDTO pictureUploadDTO, User loginUser);

    /**
     *  删除图片
     * @param pictureId
     * @param loginUser
     */
    boolean deletePicture(Long pictureId, User loginUser);

    /**
     * 获取封装图片信息
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);
    /**
     * 分页获取封装图片信息
     * @param picturePage
     * @param request
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);
    /**
     * 获取查询条件
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryDTO pictureQueryRequest);
    /**
     * 图片审核
     * @param pictureReviewDTO
     * @param loginUser
     * @return
     */
    boolean doPictureReview(PictureReviewDTO pictureReviewDTO, User loginUser);
    /**
     * 填充审核参数
     * @param picture
     * @param loginUser
     */
    void fileReviewParam(Picture picture, User loginUser);

    /**
     * 批量抓取和创建图片
     * @param loginUser
     * @return 成功创建的图片数
     */
    Integer uploadPictureByBatch(
            PictureUploadByBatchDTO pictureUploadByBatchDTO,
            User loginUser
    );

    /**
     * 清理图片
     * @param oldPicture
     */
    void clearPictureFile(Picture oldPicture);

    /**
     *  检查图片操作权限
     * @param picture
     * @param loginUser
     */
    void checkPictureAuth(Picture picture, User loginUser);

    void editPictureByBatch(PictureEditByBatchDTO pictureEditByBatchDTO, User loginUser);

    /**
     * 创建AI扩图任务
     * @param createPictureOutPaintingTaskDTO
     * @param loginUser
     * @return
     */
    CreateOutPaintingTaskResponse createPictureOutPainting(CreatePictureOutPaintingTaskDTO createPictureOutPaintingTaskDTO, User loginUser);

    void validPicture(Picture picture);
}
